package graph

import (
	"container/list"
	"fmt"
)

func GraphBFS(graph Graph){
	queue := list.New()
	queue.PushBack(graph.Nodes[1])
	nodeSet := map[*Node]struct{}{}
	nodeSet[graph.Nodes[1]] = struct{}{}
	for queue.Len() > 0 {
		node := queue.Remove(queue.Front()).(*Node)
		fmt.Println(node.Val)
		for _, next := range node.Nexts {
			if !Contains1(nodeSet, next) {
				queue.PushBack(next)
				nodeSet[next] = struct{}{}
			}
		}
	}
}
